package com.yuqian.JavaSe.niuke;

/**
 * 
 * @author yy
 *
 */
public class Transform {
	public static int[][] transformImage(int[][] mat, int n) {
		int k = 0;
		for (int i = 0; i < n ; i++) {
			for (int j = i; j < n-1-i; j++) {
				k = mat[i][j];
				mat[i][j] = mat[n - 1 - j][i];
				mat[n - 1 - j][i] = mat[n - 1-i][n - 1 - j];
				mat[n - 1 - i][n - 1 - j] = mat[j][n - 1 - i];
 				mat[j][n - 1 - i] = k;
			}
		}
		return mat;
	}

	public static void main(String[] args) {
		int[][] mat = { { 1, 2, 3 ,4}, { 5, 6,7,8 }, {  9,10,11,12 },{13,14,15,16} };
		int n = 4;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				System.out.print(mat[i][j]);
			}
			System.out.println();
		}
		Transform.transformImage(mat, n);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				System.out.print(mat[i][j]);
			}
			System.out.println();
		}
	}
}
